using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;

namespace LoggingMagic.Extensions
{
    internal static class CustomAttributeExtensions
    {
        public static bool ContainsAttributeFrom(this IEnumerable<CustomAttribute> source, HashSet<string> attributes)
        {
            return source.Any(a => attributes.Contains(a.AttributeType.FullName));
        }

        public static CustomAttribute FirstAttributeFrom(this IEnumerable<CustomAttribute> source, HashSet<string> attributes)
        {
            return source.Where(a => attributes.Contains(a.AttributeType.FullName)).FirstOrDefault();
        }
    }
}